package com.hjl.sr.util;

import java.io.UnsupportedEncodingException;

import com.hjl.sr.codec.DigestUtils;

public class BytesUtil {

	public static byte[] getBytes(String s, int maxLength) {
		if (s == null) {
			return null;
		}
		try {
			return StringUtil.substring(DigestUtils.md5Hex(s), 0, maxLength).getBytes("utf-8");
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
	}
	
	public static byte[] getBytes(String s) {
		return getBytes(s, 16);
	}
	
}
